<?php

namespace Tuobaye\FilamentAdmin\Commands;

use Illuminate\Console\Command;
use Tuobaye\FilamentAdmin\Enums\AdminStatus;
use Tuobaye\FilamentAdmin\Models\User;

class GenerateAdmin extends Command
{
    public $signature = 'generate:admin';

    public $description = '创建一个管理员账号';

    public function handle(): int
    {
        $username = $this->ask('用户名');
        $password = $this->ask('密码');
        $name = $this->ask('姓名');
        User::create([
            'username' => $username,
            'password' => $password,
            'name' => $name,
            'is_super_admin' => true,
            'status' => AdminStatus::enabled
        ]);
        $this->output->success('创建成功');

        return self::SUCCESS;
    }
}
